package com.theaf.basemodule.common.model;

import com.theaf.core.annotation.FieldCn;
import io.swagger.annotations.ApiModel;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.hibernate.annotations.DynamicUpdate;

import javax.persistence.*;
import java.io.Serializable;
import java.sql.Timestamp;
import java.util.List;

/**
 * @Author:songwenke
 * @Description:
 * @Date:create in 14:49 2017/12/21
 * @Modified By:
 **/
@ApiModel("机构表")
@Entity
@Table(name = "sys_org")
@Data
@AllArgsConstructor
@NoArgsConstructor
@DynamicUpdate
public class SysOrg implements Serializable {
    @Id
    @Column(name = "id")
    @GeneratedValue(strategy = GenerationType.SEQUENCE,generator = "org_id_req")
    @SequenceGenerator(name = "org_id_req", sequenceName = "sys_req")
    @FieldCn(value = "id")
    private Long id;
    @FieldCn(value = "上级主键")
    @Column(name = "pid")
    private Long pid;
    @FieldCn(value = "机构类型")
    @Column(name = "type")
    private String type;
    @FieldCn(value = "编码")
    @Column(name = "code")
    private String code;
    @FieldCn(value = "简称")
    @Column(name = "simple_name")
    private String simpleName;
    @FieldCn(value = "地区ID")
    @Column(name = "area_id")
    private Long areaId;
    @FieldCn(value = "全称")
    @Column(name = "full_name")
    private String fullName;
    @FieldCn(value = "级别编码",note = "（4位为一级）")
    @Column(name = "level_code")
    private String levelCode;
    @FieldCn(value = "备注")
    @Column(name = "remark")
    private String remark;
    @FieldCn(value = "是否启用")
    @Column(name = "enabled")
    private boolean enabled;
    @FieldCn(value = "状态")
    @Column(name = "state")
    private Integer state;
    @FieldCn(value = "创建者")
    @Column(name = "creater")
    private String creater;
    @FieldCn(value = "创建时间")
    @Column(name = "create_time")
    private Timestamp createTime;
    @FieldCn(value = "修改者")
    @Column(name = "updater")
    private String updater;
    @FieldCn(value = "修改时间")
    @Column(name = "update_time")
    private Timestamp updateTime;
    @FieldCn(value = "排序号")
    @Column(name = "order_no")
    private Integer orderNo;
    @OneToMany(cascade={CascadeType.ALL})
    @JoinColumn(name="data_id")
    private List<SysDataEx> others;
    @FieldCn(value = "下级允许类型")
    @Column(name = "types")
    private String types;
    public SysOrg(Long id){
        this.id = id;
    }
}
